home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
MATHS
/
RLAB
/
RLAB125.ZIP
/
!RLaB
/
help_ai
/
INTRO
< prev
next >
Wrap
Text File
|
1996-02-25
|
9KB
|
254 lines
INTRO:
Introduction to RLaB "Our"-LaB.
RLaB is a vector and matrix oriented, interactive, interpreted
programming LANGUAGE. Although RLaB started as an effort to
functionally replace MATLAB, the language and functions are
NOT MATLAB replicas. Although the language is similar to
MATLAB in some ways there are numerous differences (I hope for
the better). The help file MATLAB_DIFF briefly discusses the
primary differences between RLaB and MATLAB. If you are a
MATLAB expert please read the MATLAB_DIFF file ASAP.
The RLaB Primer is also a good starting point for new users.
It is short, and provides many introductory examples.
Using RLaB:
To get this far you must already be running RLaB. At this
point you are using the command line interface. When RLaB
confronts you with the command line prompt (`>') it is ready
to accept any valid statement. As soon as a valid statement is
recognized, RLaB will execute it. For example
> a = sqrt(2)
a =
1.41
The right-hand-side (RHS) of the expression is evaluated, and
the result is assigned to `a' immediately.
There are several data types. You do NOT need to declare
variable types, just use them (the variable(s)) in the proper
context. In the previous example `a' was a scalar. In the
following example `a' will be used as a matrix:
> a = [1,2,3;4,5,6;7,8,9]
a =
matrix columns 1 thru 3
1 2 3
4 5 6
7 8 9
The previous example created a matrix and stored it in the
variable (entity) `a'. The previous entity that `a'
represented (sqrt(2)) is destroyed.
You can use most math operators like you would in C:
a + b Addition
a - b Subtraction
a * b Matrix Multiplication
a .* b Matrix element-by-element multiply
a / b Right Division
a ./ b Element-by-element Right Division
a \ b Left Division
a .\ b Element-by-element Left Division
a^b Power
a.^b Element-by-element power
-a Unary minus (negation)
+a Unary plus
a' Matrix transpose (Hermitian transpose)
a.' Matrix element-by-element transpose
To see all of the available functions type `what()'. Try using
some:
> what()
abs error log10 plot3 solve
acos eval logspace plprint sort
acosh exist lu plptex sprintf
all exp lyap plscol0 sqrt
any eye max plsfile srand
asin factor maxi plstyle std
asinh fft mean plwid strsplt
atan filter members poly strtod
atan2 find min printf subplot
atanh finite mini printmat sum
backsub fix mod prod svd
balance floor nan pstart sylv
cd format norm ptitle symm
ceil fprintf num2str putenv system
chol fread ode pwin tan
class fseek ones qr tanh
clear fvscope open rand tic
clearall getb pause rank tmpnam
close getenv plclose rcond toc
compan getline plend read trace
complement hess pl3d readb tril
conj hilb plalt readm triu
cos ifft plaspect real type
cosh imag plaxis redit union
cross inf plaz replot what
cumprod input plcont reshape who
cumsum int plegend round whos
det int2str plerry save write
diag intersection plfont schord writeb
diary inv plgrid schur writem
diff isempty plgrid3 set xlabel
disp isinf plhist show ylabel
dlopen isnan plhistx showpwin zeros
dot issymm plhold sign zlabel
eig length plhold_off sin
eign linspace plimits sinh
eigs load plmesh size
epsilon log plot sizeof
1st enter a matrix:
> a = [1,2,3;4,5,6;7,8,9]
a =
matrix columns 1 thru 3
1 2 3
4 5 6
7 8 9
Then transpose it:
> b = a'
b =
matrix columns 1 thru 3
1 4 7
2 5 8
3 6 9
Then perform matrix multiplication with the two matrices:
> c = a * b
c =
matrix columns 1 thru 3
14 32 50
32 77 122
50 122 194
Do an element - by - element multiply:
> d = a .* b
d =
matrix columns 1 thru 3
1 8 21
8 25 48
21 48 81
Zero out the element of a that is in the 3rd row, 3rd column.
> a[3;3] = 0
a =
matrix columns 1 thru 3
1 2 3
4 5 6
7 8 0
Use det() to compute the value of the determinant of [a].
> det(a)
27
Use another built-in function to estimate the reciprocal of
the condition number:
> rcond(a)
0.01935
> 1/rcond(a)
51.67
Use another built-in function to compute the matrix inverse:
> inv(a)
matrix columns 1 thru 3
-1.778 0.8889 -0.1111
1.556 -0.7778 0.2222
-0.1111 0.2222 -0.1111
Use yet another to compute the eigenvalues, and eigenvectors
of [a]:
> eig( [1,2,3;4,5,6;7,8,9] )
val vec
Notice that eig() appears to return two variables, val, and
vec. Actually eig() returns a LIST. A LIST is an entity that
contains other entities. Functions that need to return more
than one entity do so via a LIST. See `help LIST' if LISTs are
confusing you.
The members of a list are accessed via a special syntax.
list . lname
will reference the member of the list with a name equal to
lname. For example:
> eig([1,2,3;4,5,6;7,8,9]).val
val =
matrix columns 1 thru 3
16.1 + 0i -1.12 + 0i -8.46e-16 + 0i
will return the eigenvalues of the input. If you want to save
the entire list, then save it in a variable.
> a = eig([1,2,3;4,5,6;7,8,9])
val vec
Then you can access the members of the list:
> a.val
val =
matrix columns 1 thru 3
16.1 + 0i -1.12 + 0i -8.46e-16 + 0i
> a.vec
vec =
matrix columns 1 thru 3
0.232 + 0i 0.786 + 0i 0.408 + 0i
0.525 + 0i 0.0868 + 0i -0.816 + 0i
0.819 + 0i -0.612 + 0i 0.408 + 0i
If you want to know what the names of the list members are you
can simply type the list variable at the prompt:
> a
val vec
Or, you can use the members function:
> members(a)
val vec
To see what variables are in the workspace, type `who()'
> who()
a c pi
b d pinfo
A variable can be removed from the workspace, and it's memory
freed, with the clear function:
> clear(a, d)
2
> who()
b c pi pinfo
Clear returns a number that signifies how many objects were
cleared from the workspace.
At this point you should be starting to get an idea of some of
the things RLaB can do, even though we have not yet introduced
logical operators, conditional statements, looping statements,
and user-functions.
Please skim through all the help files that are spelled with
capital letters. This will acquaint you with more features and
let you know where to go for help in the future.